using System;
using System.Collections.Generic;
using System.Text;
using PicoInterface;

namespace RapidHDL
{
    class PicoInterface : FPGAInterface 
    {
        public override bool StartClock()
        {
            bClockRunning = true;
            PicoIO.StartClock();
            return true;
        }

        public override bool StopClock()
        {
            bClockRunning = false;
            PicoIO.StopClock();
            return true;
        }

        public override bool Go(int piClockCycles)
        {
            bClockRunning = false;
            PicoIO.StartClock(piClockCycles);
            lClockCycles += piClockCycles;
            return true;
        }

        public override int ReadMemory(int piAddress)
        {
            bClockRunning = false;
            return PicoIO.Read(piAddress);
        }

        public override bool WriteMemory(int piAddress, int piValue)
        {
            bClockRunning = false;
            PicoIO.StoreAddress(piAddress);
            PicoIO.WriteData(piValue);
            return true;
        }

        public override string Start()
        {
            string sResult;
            lClockCycles = 0;
            bClockRunning = false;
            sResult = PicoIO.Attach("cfbase.bit");
            PicoIO.Reset();
            PicoIO.StartClock(50);
            return sResult;
        }

        public override bool Stop()
        {
            bClockRunning = false;
            return base.Stop();
        }

        public override bool Reset()
        {
            bClockRunning = false;
            lClockCycles = 0;
            PicoIO.Reset();
            return true;
        }
    }


}
